package com.cjw.campus.system.controller;

import com.cjw.campus.core.result.JsonResult;
import com.cjw.campus.core.utils.UploadUtil;
import com.cjw.campus.system.entity.QuestionCarouselTable;
import com.cjw.campus.system.entity.SubjectTable;
import com.cjw.campus.system.service.IQuestionCarouselTableService;
import com.cjw.campus.system.service.ISubjectTableService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cjw
 * @since 2023-03-13
 */
@RestController
@RequestMapping("/system/questionCarouselTable")
@Tag(name = "问题轮播管理接口")
public class QuestionCarouselTableController {

    @Autowired
    private IQuestionCarouselTableService iQuestionCarouselTableService;

    @PostMapping("/upload")
    @Operation(summary = "上传文件")
    public JsonResult upload (@RequestPart("file") MultipartFile file) {
        String path = UploadUtil.uploadFile(file);
        return JsonResult.ok(path);
    }

    @GetMapping("/list")
    @Operation(summary = "查询所有问题轮播图", security = { @SecurityRequirement(name = "Authorization")})
    public JsonResult list () {
        List<QuestionCarouselTable> list = iQuestionCarouselTableService.list();
        return JsonResult.ok(list);
    }

}
